#! C:\Octave\3.2.4_gcc-4.4.0\bin -qf
printf ("%s\n", program_name ());
arg_list = argv ();
nopause = 1;
nographic = 1;

for i = 1:nargin
  if (strcmp(arg_list{i},"no_pause") == 1)
		nopause = 1;
  elseif(strcmp(arg_list{i}, "no_graphic") == 1)
		nographic = 1;
  endif
endfor

%% Machine Learning Online Class - Exercise 3 | Part 2: Neural Networks

%  Instructions
%  ------------
% 
%  This file contains code that helps you get started on the
%  linear exercise. You will need to complete the following functions 
%  in this exercise:
%
%     lrCostFunction.m (logistic regression cost function)
%     oneVsAll.m
%     predictOneVsAll.m
%     predict.m
%
%  For this exercise, you will not need to change any code in this file,
%  or any other files other than those mentioned above.
%

%% Initialization
%clear ; close all; clc

%% Setup the parameters you will use for this exercise
image_size = 5;
input_layer_size  = image_size;  % 20x20 Input Images of Digits
num_labels = 3; 

%% =========== Part 1: Loading and Visualizing Data =============
%  We start the exercise by first loading and visualizing the dataset. 
%  You will be working with a dataset that contains handwritten digits.
%

% Load Training Data
fprintf('Loading Data ...\n')

data = load('onekarcinom.m');
X = data(:, (1:end));
m = size(X, 1);

% Randomly select 100 data points to display
sel = randperm(size(X, 1));
sel = sel(1:m);
if(nographic == 0)
	displayData(X(sel, :));
endif
if(nopause == 0)
	fprintf('Program paused. Press enter to continue.\n');
	pause;
endif


%% ================ Part 2: Loading Pameters ================
% In this part of the exercise, we load some pre-initialized 
% neural network parameters.

fprintf('\nLoading Saved Neural Network Parameters ...\n')
% Load the weights into variables Theta1 and Theta2
load('-binary', 'thetas.mat');

%% ================= Part 3: Implement Predict =================
%  After training the neural network, we would like to use it to predict
%  the labels. You will now implement the "predict" function to use the
%  neural network to predict the labels of the training set. This lets
%  you compute the training set accuracy.

pred = predict(Theta1, Theta2, X);
pred
filename = "result_classification.txt";
fid = fopen (filename, "w");
fprintf(fid,'%0.2f\n', pred);
fclose (fid);

if(nopause == 0)
	fprintf('Program paused. Press enter to continue.\n');
	pause;
endif


